﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace WebHoiChoMuaBan
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //routes.MapRoute(
            //    "AdminMemberRoute", // Route name
            //    "Manager/ListMember/{uid}", // URL with parameters
            //    new { controller = "Member", action = "ListNewMember" }, // Parameter defaults
            //    new string[] { "WebHoiChoMuaBan.Controllers.Admin" }
            //);
            /*=====================================ADMIN SESSION=================================================*/
            routes.MapRoute(
                "AdminMemberList", // Route name
                "Admin/Member/{action}/", // URL with parameters
                new { controller = "Member", action = "Index" }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers.Admin" }
            );

            routes.MapRoute(
               "AdminRoute", // Route name
               "Admin", // URL with parameters
               new { controller = "Member", action = "Index" }, // Parameter defaults
               new string[] { "WebHoiChoMuaBan.Controllers.Admin" }
           );



            /*=====================================PRIVATE SESSION=================================================*/
            routes.MapRoute(
                "HomeLogin", // Route name
                "DangNhap", // URL with parameters
                new { controller = "Home", action = "Login" }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers" }
            );



            routes.MapRoute(
                "PrivateHomeRoute", // Route name
                "GianHang/TrangChu/{uid}/{isEditMode}", // URL with parameters
                new { controller = "Home", action = "Index", uid = UrlParameter.Optional, isEditMode = UrlParameter.Optional }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            );

            routes.MapRoute(
                "PrivateLatestNewsRoute", // Route name
                "GianHang/BaiViet/MoiNhat/{uid}/{isEditMode}", // URL with parameters
                new { controller = "News", action = "List", uid = UrlParameter.Optional, isEditMode = UrlParameter.Optional}, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            );

            //routes.MapRoute(
            //    "PrivateDetailNewsRoute", // Route name
            //    "GianHang/BaiViet/{uid}/{newsId}/{title}/{isEditMode}", // URL with parameters
            //    new { controller = "News", action = "Detail", uid = UrlParameter.Optional, newsId = UrlParameter.Optional, title = UrlParameter.Optional, isEditMode = UrlParameter.Optional }, // Parameter defaults
            //    new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            //);

            routes.MapRoute(
                "PrivateMessageRoute", // Route name
                "GianHang/TinNhan/MoiNhat/{uid}/{page}", // URL with parameters
                new { controller = "Message", action = "List", uid = UrlParameter.Optional, page = 1 }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            );

            routes.MapRoute(
                "PrivateFriendRoute", // Route name
                "GianHang/BanBe/{uid}", // URL with parameters
                new { controller = "Friend", action = "Index", uid = UrlParameter.Optional }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            );

            routes.MapRoute(
                "PrivateMakeFriendRoute", // Route name
                "GianHang/BanBe/KetBan/{uid}", // URL with parameters
                new { controller = "Friend", action = "MakeFriend", uid = UrlParameter.Optional }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            );

            routes.MapRoute(
                "PrivateMakeFriendServiceRoute", // Route name
                "GianHang/BanBe/DanhSachCho/{uid}", // URL with parameters
                new { controller = "Friend", action = "MakeFriendService", uid = UrlParameter.Optional }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            );



            routes.MapRoute(
                "PrivatePhotoUploadRoute", // Route name
                "GianHang/HinhAnh/DangTai", // URL with parameters
                new { controller = "Photo", action = "Upload" }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            );

            routes.MapRoute(
             "PrivateAlbumDeleteRouter", // Route name
             "GianHang/Album/Xoa/{albumId}", // URL with parameters
             new { controller = "Photo", action = "DeleteAlbum", albumId = UrlParameter.Optional }, // Parameter
             new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            );

            routes.MapRoute(
             "PrivatePhotoDeleteRouter", // Route name
             "GianHang/HinhAnh/Xoa/{photoId}", // URL with parameters
             new { controller = "Photo", action = "DeletePhoto", albumId = UrlParameter.Optional }, // Parameter
             new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            );



            routes.MapRoute(
               "PrivateAdvertisement", // Route name
               "GianHang/QuangCao/{uid}", // URL with parameters
               new { controller = "Advertisement", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
               new string[] { "WebHoiChoMuaBan.Controllers.Private" }
           );


            ///routing private photo albums

            //routes.MapRoute(
            //    "PrivatePhotoRoute", // Route name
            //    "GianHang/HinhAnh/{uid}", // URL with parameters
            //    new { controller = "Photo", action = "List", uid = UrlParameter.Optional }, // Parameter defaults
            //    new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            //);


            routes.MapRoute(
             "Private_PhotoDetailRouter", // Route name
             "GianHang/HinhAnh/Detail/{uid}/{photoId}/{title}", // URL with parameters
             new { controller = "Photo", action = "Detail", uid = UrlParameter.Optional, photoId = UrlParameter.Optional, title = UrlParameter.Optional }, // Parameter
             new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            );

            routes.MapRoute(
               "PrivateProfile", // Route name
               "GianHang/SuaTrangCaNhan/{uid}", // URL with parameters
               new { controller = "Profile", action = "EditProfile", id = UrlParameter.Optional }, // Parameter defaults
               new string[] { "WebHoiChoMuaBan.Controllers.Private" }
           );



            routes.MapRoute(
                "PrivateRoute", // Route name
                "Private/{controller}/{action}/{uid}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            );


            //older
            //routes.MapRoute(
            //    "PagingPageListRoute", // Route name
            //    "TrangChuyenMuc/{pageId}/{pageNum}/{pageName}", // URL with parameters
            //    new { controller = "Home", action = "Page", pageId = 0, pageNum = 1, pageName = UrlParameter.Optional }, // Parameter defaults
            //    new string[] { "WebHoiChoMuaBan.Controllers" }
            //);

            //newer
            routes.MapRoute(
                "PagingPageListRoute", // Route name
                "TrangChuyenMuc/{pageName}", // URL with parameters
                new { controller = "Home", action = "Page", pageName = UrlParameter.Optional }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers" }
            );
            // routes.MapRoute(
            //    "NewsListRoute", // Route name
            //    "{controller}/{action}/{selectedPage}/{newsTypeId}", // URL with parameters
            //    new { controller = "News", action = "Index", selectedPage = UrlParameter.Optional, pageTypeId = UrlParameter.Optional } // Parameter defaults
            //);

            //routes.MapRoute(
            //    "ProductCreateRoute", // Route name
            //    "{controller}/{action}/{uid}", // URL with parameters
            //    new { controller = "ProductCreate", action = "Index", uid = UrlParameter.Optional } // Parameter defaults
            //);

            //routes.MapRoute(
            //   "UploadImageRouter", // Route name
            //   "{controller}/{action}/{uid}", // URL with parameters
            //   new { controller = "Upload", action = "Index", uid = UrlParameter.Optional } // Parameter
            //);

            /**********************/
            routes.MapRoute(
                "DetailPageRoute", // Route name
                "ChiTiet/{productTitle}", // URL with parameters
                new { controller = "NewsProduct", action = "Detail", productTitle = UrlParameter.Optional }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers" }
            );


            // routes.MapRoute(
            //    "DetailPageRoute1", // Route name
            //    "ChiTiet/", // URL with parameters
            //    new { controller = "NewsProduct", action = "Detail" }, // Parameter defaults
            //    new string[] { "WebHoiChoMuaBan.Controllers" }
            //);

            routes.MapRoute(
                "AddProductCommentRoute", // Route name
                "ComSanPham", // URL with parameters
                new { controller = "NewsProduct", action = "AddComment" }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers" }
            );

            //routes.MapRoute(
            //    "NewsDetailRoute", // Route name
            //    "ChiTiet/{newsId}/{newsTitle}", // URL with parameters
            //    new { controller = "NewsProduct", action = "Detail", newsId = UrlParameter.Optional, newsTitle = UrlParameter.Optional }, // Parameter defaults
            //    new string[] { "WebHoiChoMuaBan.Controllers" }
            //);

            //routes.MapRoute(
            //    "LoginRoute", // Route name
            //    "DangNhap", // URL with parameters
            //    new { controller = "Login", action = "Login" }, // Parameter defaults
            //    new string[] { "WebHoiChoMuaBan.Controllers" }
            //);

            routes.MapRoute(
                "LogoutRoute", // Route name
                "DangXuat", // URL with parameters
                new { controller = "Login", action = "Logout" }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers" }
            );

            routes.MapRoute(
                "RegisterRoute", // Route name
                "DangKy", // URL with parameters
                new { controller = "Home", action = "Register" }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers" }
            );

            routes.MapRoute(
                "HomeRoute", // Route name
                "TrangChu", // URL with parameters
                new { controller = "Home", action = "Index" }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers" }
            );

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}", // URL with parameters
                new { controller = "Home", action = "Index" }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers" }
            );

            routes.MapRoute(
                 "PrivateDefaultRoute", // Route name
                 "GianHang/{uid}/{isEditMode}", // URL with parameters
                 new { controller = "Home", action = "Index", uid = UrlParameter.Optional, isEditMode = UrlParameter.Optional }, // Parameter defaults
                 new string[] { "WebHoiChoMuaBan.Controllers.Private" }
             );

            routes.MapRoute(
                "PrivateDefaultRoute1", // Route name
                "GianHang/{uid}/{isEditMode}", // URL with parameters
                new { controller = "Product", action = "List", uid = UrlParameter.Optional, isEditMode = UrlParameter.Optional }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            );

            routes.MapRoute(
                "PrivateProductRoute", // Route name
                "GianHang/SanPham/{uid}/{isEditMode}", // URL with parameters
                new { controller = "Product", action = "List", uid = UrlParameter.Optional, isEditMode = UrlParameter.Optional }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            );

            routes.MapRoute(
                "PrivateDetailHomeRoute", // Route name
                "GianHang/TrangChu/{uid}/{isEditMode}", // URL with parameters
                new { controller = "Home", action = "Index", uid = UrlParameter.Optional, isEditMode = UrlParameter.Optional }, // Parameter defaults
                new string[] { "WebHoiChoMuaBan.Controllers.Private" }
            );

            // routes.MapRoute(
            //    "HomeSearch", // Route name
            //    "TimKiem", // URL with parameters
            //    new { controller = "Home", action = "Search" }, // Parameter defaults
            //    new string[] { "WebHoiChoMuaBan.Controllers" }
            //);

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }
    }
}